package com.neusoft.elmboot.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.neusoft.elmboot.po.Cart;
import com.neusoft.elmboot.service.CartService;
import com.neusoft.elmboot.util.APIResponse;

@RestController
@RequestMapping("/Cart")
public class CartController {
	@Autowired
	private CartService cartService;

	@GetMapping
	public APIResponse listCart(Cart cart) throws Exception {
		return APIResponse.success(cartService.listCart(cart));
	}

	@PostMapping
	public APIResponse saveCart(Cart cart) throws Exception {
			return APIResponse.success(cartService.saveCart(cart));
	}

	@PutMapping
	public APIResponse updateCart(Cart cart) throws Exception {
		return APIResponse.success(cartService.updateCart(cart));
	}

	@DeleteMapping
	public APIResponse removeCart(Cart cart) throws Exception {
		return APIResponse.success(cartService.removeCart(cart));
	}
}
